package com.huizu.project.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.huizu.common.annotation.Log;
import com.huizu.common.core.controller.BaseController;
import com.huizu.common.core.domain.AjaxResult;
import com.huizu.common.enums.BusinessType;
import com.huizu.project.domain.SysUserVo;
import com.huizu.project.service.ISysUserVoService;
import com.huizu.common.utils.poi.ExcelUtil;
import com.huizu.common.core.page.TableDataInfo;

/**
 * 后台用户新信息Controller
 * 
 * @author zhangmx
 * @date 2024-06-17
 */
@RestController
@RequestMapping("/project/sysuservo")
public class SysUserVoController extends BaseController
{
    @Autowired
    private ISysUserVoService sysUserVoService;

    /**
     * 查询后台用户新信息列表
     */
    @PreAuthorize("@ss.hasPermi('project:sysuservo:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysUserVo sysUserVo)
    {
        startPage();
        List<SysUserVo> list = sysUserVoService.selectSysUserVoList(sysUserVo);
        return getDataTable(list);
    }



    /**
     * 导出后台用户新信息列表
     */
    @PreAuthorize("@ss.hasPermi('project:sysuservo:export')")
    @Log(title = "后台用户新信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysUserVo sysUserVo)
    {
        List<SysUserVo> list = sysUserVoService.selectSysUserVoList(sysUserVo);
        ExcelUtil<SysUserVo> util = new ExcelUtil<SysUserVo>(SysUserVo.class);
        util.exportExcel(response, list, "后台用户新信息数据");
    }

    /**
     * 获取后台用户新信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('project:sysuservo:query')")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return success(sysUserVoService.selectSysUserVoByUserId(userId));
    }

    /**
     * 新增后台用户新信息
     */
    @PreAuthorize("@ss.hasPermi('project:sysuservo:add')")
    @Log(title = "后台用户新信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysUserVo sysUserVo)
    {
        return toAjax(sysUserVoService.insertSysUserVo(sysUserVo));
    }

    /**
     * 修改后台用户新信息
     */
    @PreAuthorize("@ss.hasPermi('project:sysuservo:edit')")
    @Log(title = "后台用户新信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysUserVo sysUserVo)
    {
        return toAjax(sysUserVoService.updateSysUserVo(sysUserVo));
    }

    /**
     * 删除后台用户新信息
     */
    @PreAuthorize("@ss.hasPermi('project:sysuservo:remove')")
    @Log(title = "后台用户新信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(sysUserVoService.deleteSysUserVoByUserIds(userIds));
    }
}
